{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Apple\n",
      "Apple is not red\n",
      "['Apple', 'is', 'red']\n",
      "My name is harry\n",
      "Apple\n",
      "False\n",
      "False\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "word = \"apple\"\n",
    "# 首字母大写\n",
    "print(word.replace(word[0], word[0].upper()))\n",
    "# 字符串替换 \n",
    "string = \"Apple is red\"\n",
    "str1 = string.replace(\"is\", \"is not\")\n",
    "print(str1)\n",
    "# 字符串根据空格或者其他符号拆分 \n",
    "lis = string.split(\" \")\n",
    "print(lis)\n",
    "# 字符串的连接 \n",
    "str3 = \"My name is \"\n",
    "str4 = \"harry\"\n",
    "print(str3 + str4)\n",
    "# 字符串的切片与索引 \n",
    "print(string[0:5])\n",
    "# 字符串数字和字母的判断\n",
    "str5 = \"abc\"\n",
    "print(str5.isdigit())   # 都为数字\n",
    "print(str5.isalpha())   # 都为字母\n",
    "print(str5.isalnum())   # 字母数字组合"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "c5eaa1b04e3c36593f041bc63175cf09461113a05410d10cdac056a8b8023424"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit ('base': conda)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
